<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
	window.onload = function(){

		var s = 1;//定义变量来对应显隐状态，1对应显示状态，2对应隐藏状态
		// 抓元素
		var btn = document.getElementById('btn');
		var dan = document.getElementById('dan');


		// 给按钮加事件
		btn.onclick = function(){
			if(s==1){
				// 隐藏
				dan.style.display = 'none';
				s=2;
			}else{
				// 显示
				dan.style.display = 'block';
				s=1;
			}
		}


	}
</script>
</head>

<body>

<input type="button" value="点我啊" id="btn" />

<br /><br />

<img src="dan.gif" id="dan" width="200" />


</body>
</html>
